package org.example.user.manage.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.example.commons.entity.SysUser;

/**
 * excel converter 获取sysUser中的name
 *
 * @author bothin
 */
public class GetUserNameConverter implements Converter<SysUser> {
    @Override
    public Class supportJavaTypeKey() {
        return SysUser.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public SysUser convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return (SysUser) cellData.getData();
    }

    @Override
    public CellData convertToExcelData(SysUser user, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new CellData(user.getName());
    }
}
